<?php
class Dbconn{
    const USER = 'root';
    const PASSWORD = '';
    private static $options = array(PDO:: MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
    private static $_connect;
    
    private function __construct(){} 
    private function __clone(){}
    
    public static function getConnect(){
        if(self::$_connect == null){
            try{
                self::$_connect = new PDO("mysql:host=localhost;dbname=real_blog", 
                                          self::USER, 
                                          self::PASSWORD, 
                                          self::$options
                                          );
            }catch(PDOException $e){
                echo $e->getMessage();
            }  
            self::$_connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            self::$_connect->setAttribute(PDO :: ATTR_DEFAULT_FETCH_MODE, PDO :: FETCH_ASSOC);     
        }
        return self::$_connect;    
    }
}

